<?php
session_start();

$adminName = trim($_POST['adminName']);

$pw = trim($_POST['pw']);

include_once "connect.php";

$sql = "select * from text where adminName = '$adminName' and pw = '" . md5($pw) . " ' ";

$result = mysqli_query($connect, $sql);

$num = mysqli_num_rows($result);

if ($num) {

    $_SESSION['loginadmin'] = $adminName;
    echo "<script>alert('登录成功');location.href = 'index.php';</script>";
} else {

    unset($_SESSION['loginadmin']);
    echo "<script>alert('登录失败，用户名或密码错误');history.back();</script>";
}

?>